#include "MainWin.h"
#include <QBoxLayout>
#include <iostream>

#include "View.hpp"
#include "ChessGame.hpp"

using namespace std;


MainWin::MainWin(QWidget* parent)
	: QMainWindow(parent)
{
	setupUi(this);
	this->setFixedSize(267, 350);
	connect(actionExit, SIGNAL(triggered()), this, SLOT(exit()));
}



QGraphicsView*	MainWin::getGraphicsView() const
{	return (graphicsView);	}

MainWin::~MainWin()
{}

void MainWin::closeEvent(QCloseEvent* event)
{
    int res = QMessageBox::warning(this, windowTitle(), "Are you sure?",
                QMessageBox::Yes|QMessageBox::No);
    if(res == QMessageBox::Yes)
		delete ChessGame::getInstance();
}

QPushButton*	MainWin::getCastlingButton(CastlingAction::Type type) const
{
	switch(type)
	{
		case CastlingAction::KING_SIDE:
			return (castlingKingButton);
			break;
		
		case CastlingAction::QUEEN_SIDE:
			return (castlingQueenButton);
	}
}

QAction*		MainWin::getNewAction() const
{	return (actionNew);		}

QAction*		MainWin::getSaveAction() const
{	return (actionSave);	}

QAction*		MainWin::getLoadAction() const
{	return (actionLoad);	}

QLabel*			MainWin::getStatusLabel()	const
{	return (statusLabel);	}


void			MainWin::exit()
{	closeEvent(0);		}
